import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sml_policies/locator/locator.dart';
import 'package:sml_policies/locator/sml_policies.dart';

class AppButton extends StatelessWidget {
  const AppButton({ Key? key,
    this.content,
    this.onTap,
    this.height = 50,
    this.style,
    this.child,
    this.radius = 90,
    this.lightTheme = true,
    this.outline = false,
    this.outlineColor,
    this.margin,
    this.color
  }) : super(key: key);

  final double radius;
  final String? content;
  final Function? onTap;
  final double height;
  final TextStyle? style;
  final bool lightTheme;
  final Widget? child;
  final bool? outline;
  final Color? outlineColor;
  final EdgeInsets? margin;
  final Color? color;

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: margin,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(radius),
        border: Border.all(color: outlineColor ?? const Color(0xFFFFFFFF))
      ),
      child: ClipRRect(
        borderRadius: BorderRadius.circular(radius),
        child: Material(
          borderRadius: BorderRadius.circular(radius),
          child: Ink(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(radius),
              color: color ?? locator<SmlPoliciesConfig>().mainColor
            ),
            child: InkWell(
              splashColor: Colors.white24,
              onTap: (){
                onTap?.call();
              },
              child: SizedBox(
                width: double.infinity,
                height: height.h,
                child: child ?? Center(child: Text(content!, style:
                  style ?? TextStyle(fontSize: 14, color: lightTheme ? locator<SmlPoliciesConfig>().mainColor : Colors.white, fontWeight: FontWeight.bold))),
              ),
            ),
          ),
        ),
      ),
    );
  }

}

